package test21To30;

import java.util.Scanner;

public class Test22 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (!scanner.hasNext("0")){
            int i = scanner.nextInt();
            int count =0;
            while (i/3>0){
                count+=i/3;
                i = i/3+i%3;
                if (i==2){
                    i=i+1;
                }
            }
            System.out.println(count);
        }
    }
}
